/*
 * Copyright 2012-2022 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.boot.autoconfigure.gson;

import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.LongSerializationPolicy;

import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * 用于配置 {@link Gson} 的配置属性。
 *
 * @author Ivan Golovko
 * @since 2.0.0
 */
@ConfigurationProperties(prefix = "spring.gson")
public class GsonProperties {

	/**
	 * 是否通过在输出前添加特定文本来生成不可执行的 JSON。
	 */
	private Boolean generateNonExecutableJson;

	/**
	 * 是否排除所有没有加上 "Expose" 注解的字段，不参与序列化或反序列化。
	 */
	private Boolean excludeFieldsWithoutExposeAnnotation;

	/**
	 * 是否序列化 null 字段。
	 */
	private Boolean serializeNulls;

	/**
	 * 是否启用复杂 Map 键的序列化（即非基本类型）。
	 */
	private Boolean enableComplexMapKeySerialization;

	/**
	 * 是否在序列化时排除内部类。
	 */
	private Boolean disableInnerClassSerialization;

	/**
	 * Long 和 long 类型的序列化策略。
	 */
	private LongSerializationPolicy longSerializationPolicy;

	/**
	 * 序列化和反序列化过程中应用于对象字段的命名策略。
	 */
	private FieldNamingPolicy fieldNamingPolicy;

	/**
	 * 是否输出格式化的 JSON，用于美化打印。
	 */
	private Boolean prettyPrinting;

	/**
	 * 是否宽容地解析不符合 RFC 4627 标准的 JSON。
	 */
	private Boolean lenient;

	/**
	 * 是否禁用对 HTML 字符如 '<', '>' 等的转义。
	 */
	private Boolean disableHtmlEscaping;

	/**
	 * 序列化 Date 对象时使用的格式。
	 */
	private String dateFormat;

	public Boolean getGenerateNonExecutableJson() {
		return this.generateNonExecutableJson;
	}

	public void setGenerateNonExecutableJson(Boolean generateNonExecutableJson) {
		this.generateNonExecutableJson = generateNonExecutableJson;
	}

	public Boolean getExcludeFieldsWithoutExposeAnnotation() {
		return this.excludeFieldsWithoutExposeAnnotation;
	}

	public void setExcludeFieldsWithoutExposeAnnotation(Boolean excludeFieldsWithoutExposeAnnotation) {
		this.excludeFieldsWithoutExposeAnnotation = excludeFieldsWithoutExposeAnnotation;
	}

	public Boolean getSerializeNulls() {
		return this.serializeNulls;
	}

	public void setSerializeNulls(Boolean serializeNulls) {
		this.serializeNulls = serializeNulls;
	}

	public Boolean getEnableComplexMapKeySerialization() {
		return this.enableComplexMapKeySerialization;
	}

	public void setEnableComplexMapKeySerialization(Boolean enableComplexMapKeySerialization) {
		this.enableComplexMapKeySerialization = enableComplexMapKeySerialization;
	}

	public Boolean getDisableInnerClassSerialization() {
		return this.disableInnerClassSerialization;
	}

	public void setDisableInnerClassSerialization(Boolean disableInnerClassSerialization) {
		this.disableInnerClassSerialization = disableInnerClassSerialization;
	}

	public LongSerializationPolicy getLongSerializationPolicy() {
		return this.longSerializationPolicy;
	}

	public void setLongSerializationPolicy(LongSerializationPolicy longSerializationPolicy) {
		this.longSerializationPolicy = longSerializationPolicy;
	}

	public FieldNamingPolicy getFieldNamingPolicy() {
		return this.fieldNamingPolicy;
	}

	public void setFieldNamingPolicy(FieldNamingPolicy fieldNamingPolicy) {
		this.fieldNamingPolicy = fieldNamingPolicy;
	}

	public Boolean getPrettyPrinting() {
		return this.prettyPrinting;
	}

	public void setPrettyPrinting(Boolean prettyPrinting) {
		this.prettyPrinting = prettyPrinting;
	}

	public Boolean getLenient() {
		return this.lenient;
	}

	public void setLenient(Boolean lenient) {
		this.lenient = lenient;
	}

	public Boolean getDisableHtmlEscaping() {
		return this.disableHtmlEscaping;
	}

	public void setDisableHtmlEscaping(Boolean disableHtmlEscaping) {
		this.disableHtmlEscaping = disableHtmlEscaping;
	}

	public String getDateFormat() {
		return this.dateFormat;
	}

	public void setDateFormat(String dateFormat) {
		this.dateFormat = dateFormat;
	}

}
